using System.Threading.Tasks;
using JoyfulHomeJourney.BackEnd.Infrastructure.Dtos.Requests.Objects;
using JoyfulHomeJourney.BackEnd.Server.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace JoyfulHomeJourney.BackEnd.Api.Admin.Controllers
{
	[TypeFilter(typeof(CheckLoginFilter), Arguments = new object[] { "carShop" })]
	public class CustomerOrdersController : BaseController
	{
		private readonly ICustomerOrdersServer _customerOrdersServer;
		public CustomerOrdersController(ICustomerOrdersServer customerOrdersServer)
		{
			_customerOrdersServer = customerOrdersServer;
		}
		/// <summary>
		/// 添加
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Add(RequestCustomerOrdersDto dto)
		{
			return Send(await _customerOrdersServer.AddAsync(dto));
		}
		/// <summary>
		/// 删除
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Delete(RequestCustomerOrdersDto dto)
		{
			return Send(await _customerOrdersServer.DeleteAsync(dto));
		}
		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public async Task<IActionResult> Update(RequestCustomerOrdersDto dto)
		{
			return Send(await _customerOrdersServer.UpdateAsync(dto));
		}
		/// <summary>
		/// 分页
		/// </summary>
		/// <param name="page"></param>
		/// <param name="limit"></param>
		/// <returns></returns>
		[HttpGet]
		public async Task<IActionResult> Pagination(int page,int limit)
		{
			return Send(await _customerOrdersServer.PaginationAsync(page,limit));
		}
        /// <summary>
        /// 查询统计和订单
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_orders(string timeType)
        {
			string cid = _account.AId;
            return Send(await _customerOrdersServer.Get_orders(timeType, cid));
        }
    }
}
